<%@ page pageEncoding="UTF-8" contentType="text/html;charset=UTF-8" %>

<div id="topmenu">
<table id="head" cellspacing="0" cellpadding="0">
<tr id="mainTopBlockTr">
<td height="70px" valign="top">
    <table id="head" cellspacing="0" cellpadding="0">
        <tr>
            <td width="270px"></td>
        </tr>
    </table>
</td>
<td>
    <table border="0" width="461px" height="70px" align="center" cellpadding="0px" cellspacing="0px">
        <tr>
            <td valign="center" width="461px">
                <div class="topMenuDiv">
                    <iframe src=""
                            style="filter='progid:DXImageTransform.Microsoft.Alpha(style=0,opacity=0)';filter:alpha(opacity=0);opacity:0;position:absolute; visibility:inherit; top:0px; left:0px; width:100%; height:100%; z-index:-1; ">
                    </iframe>
                    <div class="topMenuDiv_top">
                        <div id="divFloatBg"></div>
                        <%
                            for (Menu menu : usermenus) {
                                if (!StringUtil.isEmpty(menu.getUrl()) && menu.getObjorder() < -1) {
                                    String menuurl = menu.getUrl();
                                    if (!StringUtil.isEmpty(menuurl)) {
                                        Iterator paravaluehmkeyit = menuparams.keySet().iterator();
                                        while (paravaluehmkeyit.hasNext()) {
                                            String paravaluehmkey = (String) paravaluehmkeyit.next();
                                            menuurl = StringUtil.replaceString(menuurl, paravaluehmkey, (String) menuparams.get(paravaluehmkey));
                                        }
                                        menuurl = "javascript:onUrl('" + menuurl + "','" + menu.getObjname() + "','tab" + menu.getId() + "')";
                                    } else
                                        menuurl = "javascript:void(0)";
                        %>
                        <div class="menuItem" style="" onclick="<%=menuurl%>">
                            <img class="menuItemIcon" src="<%=menu.getIcon()%>"></img>

                            <DIV class="slideItemText"><%=menu.getObjname()%>
                            </DIV>
                        </div>
                        <%
                                }
                            }
                        %>


                    </div>
                    <div style="cursor:pointer;width:27px;height:55px;float:left;position:relative;top:5px;left:15px;"
                         id="topMenuContr" style="" class="menuNavSpan_Expand"></div>
                </div>
            </td>

        </tr>
    </table>

    <img src="/images/face/logo.png" border="0" id="logo"/>
    <!-- For slide-->
    <script type="text/javascript" src="/js/jquery.cycle.all.js"></script>
    <script type="text/javascript" src="/js/jquery.easing.js"></script>
    <script language="javascript">

        //顶部菜单最大高度
        var TOP_MENU_MAX_HEIGHT = "140";
        jQuery(document).ready(function () {
            //导航块移动
            jQuery(".menuItem").hover(function () {
                topMenuNavMove(this);
            }, function () {
            });
            //菜单展开或者收缩
            jQuery("#topMenuContr").bind("click", function () {
                if (jQuery(".topMenuDiv").height() > 70) {
                    jQuery(this).removeClass("menuNavSpan_Contraction");
                    jQuery(this).addClass("menuNavSpan_Expand");
                    topMenuContraction();
                } else {
                    jQuery(this).removeClass("menuNavSpan_Expand");
                    jQuery(this).addClass("menuNavSpan_Contraction");
                    topMenuExpand();
                }
            });

            //光标不在菜单区域时，如果菜单时展开的则收缩。
            jQuery(".topMenuDiv").hover(function () {
            }, function () {
                if (jQuery(".topMenuDiv").height() > 70) {
                    topMenuContraction();
                }
            });
        });

        function topMenuNavMove(_this) {
            $this = jQuery(_this);
            jQuery("#divFloatBg").show();
            jQuery("#divFloatBg").each(function () {
                jQuery.dequeue(this, "fx");
            }).animate({
                        top:$this.position().top - 3,
                        left:$this.position().left + 4
                    }, 600, 'easeOutExpo');
        }

        /**
         * 菜单收缩
         */
        function topMenuContraction() {
            jQuery("#topMenuContr").removeClass("menuNavSpan_Contraction");
            jQuery("#topMenuContr").addClass("menuNavSpan_Expand");

            jQuery(".topMenuDiv").each(function () {
                jQuery.dequeue(this, "fx")
            }).animate({
                        height:70
                    }, 0);
            if (jQuery("#divFloatBg").offset().top >= 67) {
                jQuery("#divFloatBg").hide();
            }
            jQuery(".topMenuDiv").css("background", "");
        }

        /**
         * 菜单展开
         */
        function topMenuExpand() {
            jQuery(".topMenuDiv").css("background", "url(../images/face/win7-s/menu_expand_bg.jpg)  ");
            jQuery(".topMenuDiv").css("background-position", "0 -202");
            jQuery(".topMenuDiv").css("background-repeat", "no-repeat");
            jQuery(".topMenuDiv").each(function () {
                jQuery.dequeue(this, "fx")
            }).animate({
                        height:TOP_MENU_MAX_HEIGHT
                    }, 0);
        }


    </script>

</td>
<td width="300px">
<!--放置搜索按钮框-->

<!--放常用按钮区域-->


<script type="text/javascript">
    <!--
    jQuery(document).ready(function () {
        jQuery(".tbItm").hover(function () {
            /**
             *由于IE用jQuery无法获取background-position的值，支持background-position-y，background-position-x，
             *而Safri，firefox，chrome正好相反，先使用下面方法获取background-position的值
             */
            var bp = jQuery(jQuery(this)[0]).css("background-position");
            if (bp === undefined) {
                jQuery(jQuery(this)[0]).css("background-position-y", "-25px");
            } else {
                bp = bp.split(" ", "1")[0];
                jQuery(jQuery(this)[0]).css("background-position", bp + "  -25px");
            }
        }, function () {
            var bp = jQuery(jQuery(this)[0]).css("background-position");
            if (bp === undefined) {
                jQuery(jQuery(this)[0]).css("background-position-y", "0px");
            } else {
                bp = bp.split(" ", "1")[0];
                jQuery(jQuery(this)[0]).css("background-position", bp + " 0px");
            }
        });

        jQuery(".dropdown img.flag").addClass("flagvisibility");

        jQuery(".selectTile a").click(function () {
            jQuery(".selectContent ul").toggle();
        });

        jQuery(".selectContent ul li a").click(function () {
            var text = jQuery(this).children("span").html();
            jQuery(".selectTile a").children("span").html(text);
            jQuery("input[name='searchtype']").val(jQuery(this).children("span").attr("searchType"));
            jQuery(".selectContent ul").hide();
        });
        defaultval = jQuery(".selectContent ul li a:first").children("span").attr("searchType");
        defaulttext = jQuery(".selectContent ul li a:first").children("span").html();
        jQuery(".selectTile a").children("span").html(defaulttext);
        jQuery("input[name='searchtype']").val(defaultval);
        function getSelectedValue(id) {
            return jQuery("#" + id).find("selectContent a span.value").html();
        }

        jQuery(document).bind('click', function (e) {
            var $clicked = jQuery(e.target);
            if (!$clicked.parents().hasClass("dropdown"))
                jQuery(".selectContent ul").hide();
        });


        jQuery("#flagSwitcher").click(function () {
            jQuery(".dropdown img.flag").toggleClass("flagvisibility");
        });

        jQuery("#searchbt").hover(function () {
            var bp = jQuery(jQuery(this)[0]).css("background-position");
            if (bp === undefined) {
                jQuery(jQuery(this)[0]).css("background-position-x", "-27px");
            } else {
                bp = bp.split(" ", "2")[1];
                jQuery(jQuery(this)[0]).css("background-position", "-27px " + bp);
            }
        }, function () {
            var bp = jQuery(jQuery(this)[0]).css("background-position");
            if (bp === undefined) {
                jQuery(jQuery(this)[0]).css("background-position-x", "-0px");
            } else {
                bp = bp.split(" ", "2")[1];
                jQuery(jQuery(this)[0]).css("background-position", "-0px " + bp);
            }
        });

        //更多按钮
        jQuery(".toolbarMore").bind("click", function () {
            jQuery("#toolbarMore").hide();
        });

        jQuery("#toolbarMore").hover(function () {
        }, function () {
            jQuery("#toolbarMore").hide();
        });

        //ie6下下拉菜单被select遮盖
        jQuery("#searchBlockUl iframe").css("height", jQuery("#searchBlockUl").height());

        jQuery("#searchBlockUl").hover(function () {
        }, function () {
            jQuery("#searchBlockUl").hide();
        });
        jQuery(".selectTile").hover(function () {
        }, function () {
            var clientx = event.clientX;
            var clienty = event.clientY;

            var elex = jQuery(this).offset().left;
            var eley = jQuery(this).offset().top;

            if (clientx < elex || elex > jQuery(this).offset().right || clienty < eley) {
                jQuery("#searchBlockUl").hide();
            } else {
                return;
            }
        });

    });

    function toolbarMore() {
        jQuery("#toolbarMore").toggle();
    }


    //-->
</script>


<table width="242px" align="right">
    <tr width="100%">
        <td align="right" stylt="top:0;">
            <TABLE cellpadding="0px" cellspacing="0px" height="29px;" width="201px" align="right"
                   style="margin-right:2px;">
                <tr height="100%">
                    <td style="">
                        <div class="searchBlockBgDiv"
                             style="float:left;padding-top:20px;width:140px;height:29px;background-image: url(../images/face/win7-s/searchboxImg.png);background-position: 0 -75 ;background-repeat:no-repeat;margin:0;padding:0;">

                            <form name="searchForm">
                                <input type="hidden" id="searchtype" name="searchtype" value="">

                                <div id="sample" class="dropdown" style="float:left;">
                                    <div class="selectTile">
                                        <a href="#" style="text-decoration: none;">
                                            <span style="width:25px;"></span>
                                        </a>
                                    </div>
                                    <div class="selectContent"
                                         style="margin-top:26px;*margin-top:20px;_margin-top:0px;">
                                        <ul id="searchBlockUl">
                                            <%
                                                ReportSearchfieldService reportSearchfieldService = (ReportSearchfieldService) Env.getBean("reportSearchfieldService");

                                                List setitemlist = globalsettingService.getAllSettingsByTypeId("1");

                                                Globalsetting globalsetting = new Globalsetting();
                                                FormfieldService formfieldService = (FormfieldService) Env.getBean("formfieldService");
                                                ReportService reportService = (ReportService) Env.getBean("reportService");
                                                Formfield formfield = new Formfield();
                                                Report report = new Report();
                                                List reportList = reportService.getReportList();
                                                Iterator it = setitemlist.iterator();
                                                while (it.hasNext()) {
                                                    globalsetting = (Globalsetting) it.next();
                                                    Iterator itObj = reportList.iterator();
                                                    while (itObj.hasNext()) {
                                                        report = (Report) itObj.next();
                                                        if (!report.getId().equals(globalsetting.getObjvalue())) {
                                                            continue;
                                                        }
                                                        String formfieldName = StringUtil.null2String(globalsetting.getObjdesc());
                                                        formfield = formfieldService.getFormfieldByName(report.getFormid(), formfieldName);
                                                        if (report == null || formfield == null)
                                                            continue;
                                                        String reportId = StringUtil.null2String(globalsetting.getObjvalue());
                                                        String formfieldId = "";


                                                        formfieldId = StringUtil.null2String(formfield.getId());
                                                        List<Reportsearchfield> reportsearchfields = reportSearchfieldService.getReportsearchfieldByReportid(reportId);
                                                        for (Reportsearchfield searchfield : reportsearchfields) {
                                                            if (StringUtil.null2String(searchfield.getMandatory()).equals("1") && formfieldId.equals(searchfield.getFieldid())) {
                                                                if (fillins.equals(""))
                                                                    fillins += reportId;
                                                                else
                                                                    fillins += "," + reportId;
                                                            }
                                                        }

                                                        if ("1".equals(report.getFormid())) {
                                                            formfieldId = formfieldId + ",hrm";
                                                        }
                                                        if ("2".equals(report.getFormid())) {
                                                            formfieldId = formfieldId + ",document";
                                                        }
                                            %>
                                            <li><a href="#"><span
                                                    searchType="<%=reportId+","+formfieldId%>"><%=labelService.getLabelName(globalsetting.getObjname())%></span></a>
                                            </li>

                                            <%
                                                    }
                                                }
                                            %>
                                            <%if (StringUtil.null2String(globalsettingService.get("8").getObjvalue()).equals("1")) {%>
                                            <li><a href="#"><span
                                                    searchType="lucene"><%=I18n.getText("fulltextsearch")%></span></a>
                                            </li>

                                            <%} %>


                                        </ul>
                                    </div>
                                </div>

                                <div style="float:left;margin-left: 2px">
                                    <input type="text" id="objname" name="objname" onmouseover="this.select()"
                                           style="height:22px;padding-top:3px"
                                           class="searchkeywork"/>
                                </div>


                            </form>
                        </div>

                        <div style="float:left;">
                            <div style="float:left">
                                <div class="topBlockDateBlock" onclick="quicksearch0()"
                                     style="float:left;cursor:pointer;font-weight:bold;color:#003366;background:url(../images/face/win7-s/searchboxImg.png);background-position: -148px -75px;background-repeat: no-repeat;width:54px;height:29px;line-height:32px;text-align:center;">
                                    搜索
                                </div>
                            </div>

                            <div style="float:left;display:block;background:url(../images/face/win7-s/searchboxImg.png);background-position: -252 -75px;background-repeat: no-repeat;width:6px;height:29px;"
                                 class="toolbarTopRight">
                            </div>
                        </div>
                    </td>
                </tr>
            </TABLE>
        </td>
    </tr>

    <tr>
        <td height="2px;"></td>
    </tr>

    <tr style="border:1px solid red;" width="100%" align="bottom">
        <td width="100%">
            <TABLE cellpadding="0px" cellspacing="0px" style="margin-top:5px;" width="100%" align="right">
                <tr align="left">
                    <!-- 刷新 -->
                    <td onClick="doRefresh()"
                        title="<%=I18n.getText("refresh")%>">
                        <span style="background-position:-25 0;display:block;" class="tbItm"></span>
                    </td>


                    <td onclick="javascript:toolbarMore();" title="更多" style="position:relative;">
                        <span style="background-position:-270 0;display:block;" class="tbItm"></span>
                    </td>
                    <td style="position:absolute;right:180px;">
                        <div id="toolbarMore" style="display:none;position:absolute;width:184px;right:0;top:22;">
                            <div id="toolbarMoreBlockTop"
                                 style="background-image:url(../images/face/win7-s/toolbarMoreTop.png);background-repeat:no-repeat;height:11px;overflow:hidden;width:184px;"></div>
                            <TABLE cellpadding="10" cellspacing="3px" align="center" width="100%"
                                   style="margin:0;background-image:url(../images/face/win7-s/toolbarMoreCenter.jpg);background-repeat:repeat-y;">
                                <tr>
                                    <td colspan="5" height="5px"></td>
                                </tr>
                                <tr align="center">
                                    <td onclick="leftBlockContractionOrExpand();" title="隐藏" style="position:relative;">
                                        <span style="background-position:-295 0;display:block;" class="tbItm"></span>
                                    </td>

                                    <td onclick="topBlockContractionOrExpand();" title="隐藏" style="position:relative;">
                                        <span style="background-position:-320px 0;display:block;" class="tbItm"></span>
                                    </td>

                                    <td onclick="openwinlics()" title="<%=I18n.getText("about")%>">
                                        <span style="background-position:-200 0;display:block;" class="tbItm"
                                              class="toolbarMore"></span>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="5" height="5px"></td>
                                </tr>
                            </TABLE>
                            <TABLE cellpadding="0px" cellspacing="0px" height="5px" width="100%"
                                   style="background:url(../images/face/win7-s/toolbarMoreBottom.png);background-repeat: no-repeat;">
                                <tr>
                                    <td height="5px"></td>
                                </tr>
                            </TABLE>

                        </div>
                    </td>

                    <td onclick="javascript:toolbarLogOff()"
                        title="<%=I18n.getText("exit")%>">
                        <span style="background-position:-225 0;display:block;" class="tbItm"></span>
                    </td>
                </tr>
            </TABLE>
        </td>

    </tr>
</table>
</tr>
</table>

</div>
<script type="text/javascript">
    jQuery(document).ready(function () {
        if (typeof(quicksearch0) == 'function') {
            quicksearch0 = function () {
                var _objvalue = document.getElementById("objname").value;
                var param = document.getElementById("searchtype").value;

                var selectText = jQuery(".selectTile a").children("span").html();
                ;

                if (param == 'lucene') {
                    if (!_objvalue) {
                        pop('<%=I18n.getText("00026")%>');
                        return;
                    }
                    qsurl = contextPath + "/fts.do?action=search&key=" + _objvalue;
                    if (Ext.isGecko)
                        ;
                    else
                        qsurl = encodeURI(qsurl);
                    onUrl(qsurl, selectText, 'qslucene');
                    return;
                }
                var reportid = param.substring(0, param.indexOf(","));
                var field = param.substring(param.indexOf(",") + 1);
                if (fillins.indexOf(reportid) > -1) {
                    if (_objvalue == '') {
                        pop('<%=I18n.getText("00026")%>');
                        return;
                    }
                }
                qsurl = contextPath + "/reportdata.do?action=search&reportid=" + reportid + "&con" + field + "_value=" + _objvalue;
                if (Ext.isGecko)
                    ;
                else
                    qsurl = encodeURI(qsurl);
                onUrl(qsurl, selectText, 'qs' + reportid);
            }
        }

    })

</script>
